<?php
/**
 * Created by PhpStorm.
 * User: zw
 * Date: 2018/10/24
 * Time: 10:34
 */
require 'vendor/autoload.php';

use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;


function getUUID($param = '')
{
    if (empty($param)) {
        return '********-****-****-****-************';
    } else {
        try {
            // Generate a version 5 (random) UUID object
            $uuid4 = Uuid::uuid5(Uuid::NAMESPACE_DNS, $param);
            return $uuid4->toString(); // i.e. 25769c6c-d34d-4bfe-ba98-e0ee856f3e7a
        } catch (UnsatisfiedDependencyException $e) {
            // Some dependency was not met. Either the method cannot be called on a
            // 32-bit system, or it can, but it relies on Moontoast\Math to be present.
            return 'Caught exception: ' . $e->getMessage();
        }
    }
}

if (!empty($_GET['param'])) {
    $param = $_GET['param'];
} else {
    $param = '';
}

echo getUUID($param);